<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

	电话：<input name="phone" type="text"/> <br/>
	密码：   <input name="password" type="password">
	
	<input  type="reset" value="重置"> 
	<input id="scott" type="button" value="注册"> 

</body>

	<script src="js/jquery.min.js"></script>
	
	
	<script type="text/javascript">
	
		$(function(){
			
			$('#scott').click(function(){
				
				var phone = $('input[name="phone"]').val();
				var password = $('input[name="password"]').val();
			
				
				$.ajax({
					
					url:'${pageContext.request.contextPath}/user/register',
					type:'post',
					data:{
						'phone':phone,
						'password':password,
					},
					dataType:'json',
					success:function(data){
						var message = data.message;
						if(message == 'success'){
							window.location.href='${pageContext.request.contextPath}/login.jsp';
						}else{
							window.location.href='${pageContext.request.contextPath}/regist.jsp';
						}
					}
				});
				
			});
		});
	
	</script>
</html>